package svc

import (
	"github.com/zeromicro/go-zero/core/stores/redis"
	"github.com/zeromicro/go-zero/core/stores/sqlx"
	"go-zero-starter/src/internal/config"
)

type ServiceContext struct {
	Config  config.Config
	Redis   *redis.Redis
	SqlConn sqlx.SqlConn
}

func NewServiceContext(c config.Config) *ServiceContext {

	sqlConn := sqlx.NewMysql(c.DataSource)

	return &ServiceContext{
		Config:  c,
		Redis:   redis.MustNewRedis(c.RedisConf),
		SqlConn: sqlConn,
	}
}
